package com.sy.cloud;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CommonExceptionHandler implements HandlerExceptionResolver {
    
    private Logger logger = LoggerFactory.getLogger(CommonExceptionHandler.class);

    @Override
    public ModelAndView resolveException(HttpServletRequest request,
                                         HttpServletResponse response, Object handler, Exception ex) {
        if ("ClientAbortException".equals(ex.getClass().getSimpleName())) {
            logger.warn("Client aborted.");
        } else {
            logger.error("exception caught, this should be an error or bug", ex);
        }
        return null;
    }

}
